[ASTERIXDB-3021][COMP] Emit cross product warning for implicit joins#49
Open
pineappleBest123 wants to merge 1 commit intoapache:masterfrom
Open
Conversation
When a query uses implicit cross join syntax (FROM A, B without a join condition), SimpleUnnestToProductRule rewrites the unnest pipeline into an InnerJoinOperator with a constant TRUE condition but never emits a warning. Explicit JOIN ... ON TRUE already triggers the CROSS_PRODUCT_JOIN warning via JoinUtils. This change closes that gap. - Change warnIfCrossProduct() in JoinUtils from private to public - Call JoinUtils.warnIfCrossProduct() in SimpleUnnestToProductRule after the cross product join is constructed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a SQL++ query uses implicit cross join syntax (e.g.,
FROM customers, orderswithout an explicit join condition),
SimpleUnnestToProductRulerewrites the unnestpipeline into an
InnerJoinOperatorwith a constantTRUEcondition. However, nowarning is emitted to alert the user that a cross product is being performed.
By contrast, an explicit
JOIN ... ON TRUEalready triggers aCROSS_PRODUCT_JOINwarning through
JoinUtils.warnIfCrossProduct(). This inconsistency means users ofthe implicit syntax receive no feedback about potentially expensive cross products,
which can lead to unexpected performance issues or incorrect query results.
Changes
JoinUtils.javawarnIfCrossProduct()fromprivate statictopublic staticso it canbe called from outside the class.
SimpleUnnestToProductRule.javaimportforJoinUtils.JoinUtils.warnIfCrossProduct()immediately after the cross productjoin operator is constructed, consistent with how explicit joins are handled.
Testing
mvn compilepasses on thealgebricks-rewritermodule.mvn testpasses (BUILD SUCCESS) on thealgebricks-rewritermodule.Related